"""爬虫"""
import requests
from bs4 import BeautifulSoup

baidu_url = 'https://www.baidu.com'
response = requests.get(baidu_url)
if response.status_code == 200:
    print(response.encoding)
    response.encoding = 'utf-8'
    print(response.text)

# 创建bs对象
soup = BeautifulSoup(response.text, 'html.parser')
print(type(soup))
head = soup.head
print(head)

# tag对象的属性
print(head.name)  # 输出标签名
print(head.attrs)  # 输出属性字典
print(head.contents)  # 输出标签的内容
print(head.string)  # 输出字符串内容



